package com.itfreer.special.report;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itfreer.form.api.BaseRestService;
import com.itfreer.form.api.BaseService;
import com.itfreer.utils.ResponseEntity;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 定义报表Rest服务接口
 */
@RestController
@RequestMapping("/specialreport")
@Api("报表")
public class RestSpecialReportService extends BaseRestService<SpecialReportEntity> {

	@Autowired(required = false)
	private SpecialReportService service;

	@Reference(lazy = true, check = false)
	private SpecialReportService dubboService;

	@Override
	protected BaseService<SpecialReportEntity> getService() {
		return getServiceEx();
	}

	private SpecialReportService getServiceEx() {
		if (service == null) {
			return dubboService;
		} else {
			return service;
		}
	}

	@ApiOperation(value = "根据报表ID获取定义ID", notes = "根据报表ID获取定义ID")
	@PostMapping(value = "/getDicIdById", produces = "application/json")
	public ResponseEntity<String> checkCoatMoney(@RequestBody String id) {
		String result = getServiceEx().getDicIdById(id);
		return new ResponseEntity<String>(result);
	}
}
